package com.aramis.mydytt.ui.topic.detail

import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.aramis.mydytt.R
import com.aramis.mydytt.ui.base.BaseViewHolder
import com.aramis.mydytt.ui.bean.MovieSpecialDetailBean
import com.aramis.mydytt.ui.bean.MovieSpecialDetailItemBean
import com.facebook.drawee.view.SimpleDraweeView

/**
 * Description: TopicDetailListAdapterItemViewHolder
 * @author lizhidan
 * Created: 2021/5/24
 */
class TopicDetailListAdapterItemViewHolder(
    parent: ViewGroup,
    var onMovieItemClickListener: ((MovieSpecialDetailItemBean) -> Unit)?
) :
    BaseViewHolder<MovieSpecialDetailBean>(parent, R.layout.item_topic_detail_content) {
    private val movieCoverView: SimpleDraweeView = itemView.findViewById(R.id.image_topic_detail_movie_cover)
    private val movieNameView: TextView = itemView.findViewById(R.id.text_topic_detail_movie_name)
    private val dividerView: View = itemView.findViewById(R.id.view_divider)

    override fun bind(m: MovieSpecialDetailBean, position: Int) {
        m.video?.get(position - 1)?.apply {
            movieCoverView.setImageURI(path)
            movieNameView.text = title
            itemView.setOnClickListener { onMovieItemClickListener?.invoke(this) }

            val size = m.video.size
            dividerView.visibility = if (position - (size / 3 * 3) >= 0) View.VISIBLE else View.GONE
        }
    }

}